package com.grace.cms.forum.user.controller.api;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.grace.common.core.domain.AjaxResult;
import com.grace.cms.common.enums.RecordTypeEnums;
import com.grace.cms.forum.user.service.tadlib.CommentTag;
@CrossOrigin
@RestController
@RequestMapping("/{themeName}/api/comment")
public class CommentApiController {

    @Autowired
    private CommentTag commentTag;

    @GetMapping("/{recordType}/treePage")
    public AjaxResult listCommentTree(@PathVariable("themeName") String themeName,@PathVariable("recordType") RecordTypeEnums recordType, String recordId, int pageNum,
            int pageSize) {
        return AjaxResult.success(commentTag.pageCommentTree(recordType.getPrefix(recordId), recordType, themeName, pageNum, pageSize));
    }

    @GetMapping("/{recordType}/firstLeavePage")
    public AjaxResult listCommentOne(@PathVariable("themeName") String themeName,@PathVariable("recordType") RecordTypeEnums recordType, String recordId, int pageNum,
            int pageSize) {
        return AjaxResult.success(commentTag.pageCommentFirstLeave(recordId, recordType, themeName, pageNum, pageSize));
    }

    @GetMapping("/{recordType}/secondLeavePage")
    public AjaxResult listCommentTwo(@PathVariable("themeName") String themeName,@PathVariable("recordType") RecordTypeEnums recordType, long parentId, int pageNum,
            int pageSize) {
        return AjaxResult.success(commentTag.pageCommentSecondLeave(parentId, recordType, themeName, pageNum, pageSize));
    }

}
